home *** CD-ROM | disk | FTP | other *** search
/ Shareware Grab Bag / Shareware Grab Bag.iso / 014 / libtools.arc / UNWS.AQM / UNWS.ASM
Encoding:
Assembly Source File  |  1984-04-08  |  5.8 KB  |  191 lines

  1. ;gaithersburg md pc bb 19 mar 83
  2. ;Updated: 05/01/82.    8463 Bytes.  Xmit Time:    4:42
  3. ;
  4. TITLE NWS - ASSEMBLER PROGRAM TO STRIP HI-ORDER BITS FROM WORDSTAR FILES
  5. SUBTTL DESCRIPTION OF THE STACK SEGMENT
  6.     PAGE
  7. STACK    SEGMENT PARA STACK 'STACK'
  8.     DB    64 DUP('STACK   ')
  9. STACK    ENDS
  10. SUBTTL DESCRIPTION OF THE DATA SEGMENT
  11.     PAGE
  12. WORKAREA SEGMENT PARA PUBLIC 'DATA'
  13. LOGO    DB    '       ***********************************************************************',10,13
  14.     db    '       *                                                                     *',10,13
  15.     db    '       *                        UN - Wordstar                                *',10,13
  16.     db    '       *   A program to remove the high-order bits from Wordstar data        *',10,13
  17.     db    '       *   files.  You are prompted for the input and output file names.     *',10,13
  18.     db    '       *                                                                     *',10,13
  19.     db    '       *     Written as an assembler language example by Gene Plantz         *',10,13
  20.     db    '       ***********************************************************************',10,10,10,10,13,'$'
  21. donem    db    '-------->    DONE    <-------------',10,13,'$'
  22. eofflag db    0
  23. crlf    db    10,13,'$'       ;issue carriage return-linefeed after input
  24. fcb1    db    40 dup(0)    ;input file  only needs to be 36 (but safe)
  25. fcb2    db    40 dup(0)    ;file control block for output
  26. err0    db    7,7,'--->  ERROR Opening INPUT file  <--------',10,13,'$'
  27. err1    db    7,7,'--->  ERROR.. not enough disk space for output <---',10,13,'$'
  28. err2    db    7,7,'--->  ERROR.... bad file name given. <----',10,13,'$'
  29. parms    db    14        ;max size of reply
  30. repson    db    ?        ;size of what they typed
  31. name1    db    20  dup(' ')    ;this is where the users reply goes
  32. parms2    db    14        ;max size of input
  33. resp2    db    ?        ;size of what they really typed in
  34. name2    db    20  dup(' ')    ;this is where the reply goes
  35. ask1    db    10,10,13,'Please Enter the name of the input file    $'
  36. ask2    db    'Please Enter the name of the output file   $'
  37. buffer    db    128 dup(' ')            ;record  buffer
  38. workarea ends
  39. ;
  40. subttl desciption of dos interfaces
  41. cseg    segment para public 'CODE'
  42. start    proc    far
  43.     assume cs:cseg,ds:workarea,ss:stack,es:workarea
  44.     org    100h
  45.     push    ds            ;set up starting linkage as per dxample
  46.     sub    ax,ax            ;zero this and place on stack
  47.     push    ax            ;so that when we do a RET we go to
  48.     mov    ax,workarea        ;location 0;  point to our workarea
  49.     mov    ds,ax            ;move the workarea address into DS
  50.     mov    es,ax            ;also into ES for the function 29H
  51.     call    cls            ;call subroutine to clear the screen
  52.     mov    dh,3            ;set cursor to row 8
  53.     mov    dl,0            ;set cursor to column 0
  54.     mov    bh,0            ;use screen number 0
  55.     mov    ah,2            ;function 2 to locate cursor
  56.     int    10h            ; go do it
  57.     mov    dx,offset logo        ;display the logo where we put cursor
  58.     mov    ah,9            ;function 9 is print string
  59.     int    21h            ;call dos to do it
  60. ;
  61.     mov    dx,offset ask1        ;point to message to display
  62.     mov    ah,9            ;tell DOS what function (print string)
  63.     int    21h            ;call DOS
  64. ;
  65.     mov    dx,offset parms     ;point to console input buffer
  66.     mov    ah,10            ;read console buffer
  67.     int    21h            ;do it
  68. ;
  69.     mov    si,offset name1     ;put address of name1 into SI
  70.     mov    di,offset fcb1        ;put address of file control block DI
  71.     mov    ah,29h            ;tell DOS to parse filename
  72.     int    21h            ;do it
  73. ;
  74.     mov    dx,offset crlf        ;do a carriage return-line feed
  75.     mov    ah,9            ;after the reply
  76.     int    21h            ;to DOS
  77. ;
  78.     mov    al,[di+1]        ;if DI+1 = blank, no file name
  79.     cmp    al,20h            ;if blank, error
  80.     jnz    isok
  81.     jmp    error2
  82. ;
  83. isok:
  84.     mov    dx,offset ask2        ;ask user for name of new file
  85.     mov    ah,9            ;display question
  86.     int    21h            ;DOS
  87. ;
  88.     mov    dx,offset parms2    ;put address of input buffer into DX
  89.     mov    ah,10            ;get input from user
  90.     int    21h            ;DOS
  91. ;
  92.     mov    dx,offset crlf        ;another cr,lf
  93.     mov    ah,9
  94.     int    21h
  95. ;
  96.     mov    si,offset name2     ;SI = address of field NAME2
  97.     mov    di,offset fcb2        ;DI = address of second file control
  98.     mov    ah,29h            ;ask DOS to parse filename
  99.     int    21h            ;DOS
  100. ;
  101.     mov    al,[di+1]        ;if DI+1 = blank, error
  102.     cmp    al,20h            ;is it blank??
  103.     jz    error2            ;tell him and leave    yyyyy
  104. ;
  105.     mov    dx,offset fcb1        ;point to first fcb
  106.     mov    ah,15            ;open the input file
  107.     int    21h            ;call dos to do it
  108. ;
  109.     cmp    al,0            ;see if ok
  110.     jnz    error0            ;tell him and leave
  111. ;
  112.     mov    dx,offset fcb2        ;address of fcb2
  113.     mov    ah,16h            ;create out put file
  114.     int    21h            ;this does open, too
  115. ;
  116.     mov    dx,offset buffer    ;point to out record buffer
  117.     mov    ah,1ah            ;tell DOS to put disk data there
  118.     int    21h            ;DOS
  119. ;
  120. readl:    cmp    eofflag,1        ;see if end-of-file was reached
  121.     jz    closeall        ;yes, wrap it up and leave
  122.     mov    dx,offset fcb1        ;read from file 1
  123.     mov    ah,14h            ;sequential read from disk
  124.     int    21h            ;DOS
  125. ;
  126.     cmp    al,0            ;see if normal return
  127.     jz    readok            ;if zero, ok
  128.     mov    eofflag,1        ;error or eof, set end-of-file flag
  129.     cmp    al,03            ;see if eof and data too
  130.     jz    readok            ;if 03 we have both
  131.     jmp    readl            ;back to read
  132. ;
  133. readok:
  134.     mov    cx,128            ;size of logical record
  135.     mov    si,offset buffer    ;SI = address of our buffer
  136. andloop:
  137.                     ;these 3 lines were used because
  138.                     ;   AND [SI],7FH    wouldn't assemble
  139.                     ;
  140.     mov    al,[si]         ;and out the hi-bit
  141.     and    al,7fh
  142.     mov    [si],al         ;put it back
  143. ;
  144.     inc    si            ;bump pointer to next char in buffer
  145.     loop    andloop         ;do it 128 times (in CX)
  146. ;
  147.     mov    dx,offset fcb2        ;point to output fcb
  148.     mov    ah,15h            ;sequential write
  149.     int    21h
  150.     cmp    al,1            ;this means disk full
  151.     jz    error1
  152. ;
  153.     jmp    readl            ;do it again
  154. ;
  155. closeall:
  156.     mov    dx,offset fcb2        ;close output file
  157.     mov    ah,10h
  158.     int    21h
  159. ;
  160.     mov    dx,offset donem     ;iisue DONE message
  161.     mov    ah,9
  162.     int    21h
  163.     jmp    exit
  164. ;
  165. error2: mov    dx,offset err2        ;err mess 2
  166.     jmp    errorm
  167. error1: mov    dx,offset err1        ;point to error mess number 1
  168.     jmp    errorm
  169. error0: mov    dx,offset err0
  170. errorm:
  171.     mov    ah,9            ;print it
  172.     int    21h
  173.     jmp    closeall
  174. exit:    ret
  175. start    endp
  176. ;
  177. ;
  178. subttl clear screen routine
  179. cls    proc    near
  180.     mov    cx,0
  181.     mov    dx,2479h
  182.     mov    bh,7
  183.     mov    ax,600h
  184.     int    10h
  185.     ret
  186. cls    endp
  187. ;
  188. ;
  189. cseg    ends
  190.     end    start
  191.